package com.tsingtree.modular.controller.view;

import com.tsingtree.base.auth.annotion.Permission;
import com.tsingtree.modular.entity.NanSellAnnounceBanner;
import com.tsingtree.modular.model.params.NanSellAnnounceBannerParam;
import com.tsingtree.modular.service.NanSellAnnounceBannerService;
import com.tsingtree.roses.core.base.controller.BaseController;
import com.tsingtree.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 社区Banner控制器
 *
 * @author jagger
 * @since 2025-10-18
 */
@Controller
@RequestMapping("/nanSellBanner")
public class NanSellAnnounceBannerController extends BaseController {

    private String PREFIX = "/nanSellBanner";

    @Autowired
    private NanSellAnnounceBannerService nanSellAnnounceBannerService;

    /**
     * 跳转到Banner管理页面
     */
    @RequestMapping("/list")
    public String list() {
        return PREFIX + "/list.html";
    }

    /**
     * 获取Banner列表（API接口）
     */
    @ResponseBody
    @RequestMapping("/listData")
    public ResponseData listData() {
        List<NanSellAnnounceBanner> list = nanSellAnnounceBannerService.findAllBanners();
        return ResponseData.success(list);
    }

    /**
     * 新增Banner
     */
    @RequestMapping("/add")
    @Permission
    @ResponseBody
    public ResponseData add(NanSellAnnounceBannerParam nanSellAnnounceBannerParam) {
        this.nanSellAnnounceBannerService.add(nanSellAnnounceBannerParam);
        return ResponseData.success();
    }

    /**
     * 删除Banner
     */
    @RequestMapping("/delete")
    @Permission
    @ResponseBody
    public ResponseData delete(NanSellAnnounceBannerParam nanSellAnnounceBannerParam) {
        this.nanSellAnnounceBannerService.delete(nanSellAnnounceBannerParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(NanSellAnnounceBannerParam nanSellAnnounceBannerParam) {
        NanSellAnnounceBanner detail = this.nanSellAnnounceBannerService.findById(nanSellAnnounceBannerParam);
        return ResponseData.success(detail);
    }

}
